/****Login.aspx的后台********/
Response.Write("欢迎用户"+Session["UserName"].ToString ()+"登录本系统!
");
Response.Write("您登录的时间为:"+Session["LoginTime"].ToString ());
/*************在前台建立一个用户名txtUserName,2个按钮btnLogin和btnCancel***后台程序如下***********/
protected void btnLogin_Click(object sender, EventArgs e)
{
if (txtUserName.Text=="mr" && txtPwd .Text =="mrsoft")
{
Session["UserName"] = txtUserName.Text;//使用Session变量记录用户名
Session["LoginTime"] = DateTime.Now;//使用Session变量记录用户登录系统的时间
Response.Redirect("~/Welcome.aspx");//跳转到主页
}
else
{
Response.Write("");
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
txtPwd.Text = "";
txtUserName.Text = "";
}